home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / zendisk1.zip / LST9-24.ASM < prev    next >
Assembly Source File  |  1990-02-15  |  893b  |  39 lines

  1. ;
  2. ; *** Listing 9-24 ***
  3. ;
  4. ; Performs binary-to-ASCII conversion of a byte value
  5. ; by using AAM.
  6. ;
  7.     jmp    Skip
  8. ;
  9. ResultString    db    3 dup (?)
  10. ResultStringEnd    label    byte
  11.     db    0    ;a zero to mark the string end
  12. ;
  13. Skip:
  14. BYTE_VALUE=0
  15.     call    ZTimerOn
  16.     rept    100
  17.     std        ;make STOSB decrement DI
  18.     mov    ax,ds
  19.     mov    es,ax    ;for STOSB
  20.     mov    bl,'0'    ;used for converting to ASCII
  21.     mov    di,offset ResultStringEnd-1
  22.     mov    al,BYTE_VALUE
  23.     aam        ;put least significant decimal
  24.             ; digit of BYTE_VALUE in AL,
  25.             ; other digits in AH
  26.     add    al,bl    ;make it an ASCII digit
  27.     stosb        ;save least significant digit
  28.     mov    al,ah
  29.     aam        ;put middle decimal digit in AL
  30.     add    al,bl    ;make it an ASCII digit
  31.     stosb        ;save middle digit
  32.             ;most significant decimal
  33.             ; digit is in AH
  34.     add    ah,bl    ;make it an ASCII digit
  35.     mov    [di],ah    ;save most significant digit
  36. BYTE_VALUE=BYTE_VALUE+1
  37.     endm
  38.     call    ZTimerOff
  39.